package com.firewol.spring.handlers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;

import com.firewol.spring.entities.User;
import com.firewol.spring.service.IUserService;

@Controller
public class UserController {
	
	@Autowired(required=false)
	//使用required=false表明可以不用装配
	private User user;
	
	//使用@Value装配字面值
	@Value("liuxing")
	private String name;
	
	//当存在多个能按类型匹配上的Bean的时候，使用@Qualifier限定歧义
	@Autowired
	@Qualifier("userService1")
	private IUserService service;
	
	public void addUser(){
		System.out.println(name);
		service.save();
	}
}
